<?php

!defined('SYSTEM_INCLUDED') && exit('Access Denied');

SysBase::import('System.Validators.PatternValidator');

/*只允许整数形式*/

Class IntegerValidator extends PatternValidator{
	
	public $pattern='/^[0-9]+$/';
	
	public $min;
	
	public $max;
	
	public $errorMsg = 'Pattern Validate Error! Only Integer are allowed!'; 


	public function validate($num,$pattern = null){
		parent::validate($num);
		if($this->min && ($num < $this->min) ){
			throw new ValidatorException ('The Integer is Lower than required!');
		}
		if($this->max && ($num > $this->max) ){
			throw new ValidatorException ('The Integer is Higher than required!');
		}
		return true;
	}

}
